package com.atguigu.servicebase.exception;

import com.atguigu.servicebase.result.ResponseEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;


@Slf4j
public abstract class Assert {

    public static void notNull(Object obj, ResponseEnum responseEnum) {
        if (obj == null) {
            log.info("obj is null...............");
            throw new ServiceException(responseEnum);
        }
    }

    public static void notFalse(boolean b, ResponseEnum responseEnum) {
        if (!b) {
            throw new ServiceException(responseEnum);
        }
    }

    public static void notZero(Integer count, ResponseEnum responseEnum) {
        if (count == 0) {
            throw new ServiceException(responseEnum);
        }
    }

    public static void notEmpty(String string, ResponseEnum responseEnum) {
        if (StringUtils.isEmpty(string)) {
            throw new ServiceException(responseEnum);
        }
    }
}
